package thefirst.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class LoginCheckInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		HttpSession session= request.getSession(false);//session 이 없어도 새로 생성 안해준다.
		if(session ==null || session.getAttribute("mvo")==null){
			System.out.println("로그인 후 수행 가능합니다.");
			
			response.sendRedirect("loginResult.do?path="+request.getServletPath());
			return false;
		}
		return true;
	}
}
